import Vue from 'vue'
import Vuex from 'vuex'
import {getlogin} from "../utils/api"
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token:""
  },
  getters: {
  },
  mutations: {
    getlogin(state,token){
      state.token=token
      localStorage.setItem("token",state.token)
    }
  },
  actions: {
    getlogin({commit},obj){
     return new Promise((resolve, reject) => {
        getlogin(obj).then(res=>{
          console.log(18,res);
          commit("getlogin",res.data.token)
          resolve(res)
        })
      })
    }
  },
  modules: {
  }
})
